package com.tfswue.jqr;

import com.tfswue.jqr.config.MyConfig;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

// 开启缓存——Redis
@EnableCaching
//swagger
@OpenAPIDefinition(info = @Info(title = "Book Service API", version = "1.0"))
//开启远程调用
@EnableFeignClients
@MapperScan("com.tfswue.jqr.mapper")
//开启负载均衡
@LoadBalancerClients(defaultConfiguration = {MyConfig.class})
@SpringBootApplication
public class BorrowServiceApplication {
    public static void main(String[] args) {
        SpringApplication.run(BorrowServiceApplication.class, args);
    }
    @Bean
    //开启负载功能
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }// 创建RestTemplate实例，用于调用其他服务，同理postman接口测试，远程调用userService，获取用户信息
}
